package com.yihu.wlyy.service.app.scheduling;

import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.yihu.wlyy.entity.doctor.DoctorScheduling;
import com.yihu.wlyy.entity.doctor.DoctorSchedulingTimes;
import com.yihu.wlyy.repository.DoctorSchedulingDao;
import com.yihu.wlyy.repository.DoctorSchedulingTimesDao;
import com.yihu.wlyy.service.BaseService;

/**
 * 医生排班业务处理类
 * @author George
 *
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class DoctorSchedulingService extends BaseService {
	
	@Autowired
	private DoctorSchedulingDao doctorSchedulingDao;
	@Autowired
	private DoctorSchedulingTimesDao doctorSchedulingTimesDao;
	
	/**
	 * 查询医生排班设置
	 * @param team
	 * @return
	 */
	public List<DoctorScheduling> findDoctorVideoScheduling(String team){
		List<DoctorScheduling> list = new ArrayList<DoctorScheduling>();
		Iterable<DoctorScheduling> iterable = doctorSchedulingDao.findByTeam(team);
		if(iterable != null){
			Iterator<DoctorScheduling> it = iterable.iterator();
			while(it != null && it.hasNext()){
				DoctorScheduling ds = it.next();
				list.add(ds);
			}
		}
		return list;
	}
	
	/**
	 * 查询医生指定时间段的预约情况
	 * @param team
	 * @param begin
	 * @param end
	 * @return
	 */
	public List<DoctorSchedulingTimes> findDoctorVideoSchedulingTimes(String team, Date begin, Date end){
		List<DoctorSchedulingTimes> list = new ArrayList<DoctorSchedulingTimes>();
		Iterable<DoctorSchedulingTimes> iterable = doctorSchedulingTimesDao.findByTeam(team, begin, end);
		if(iterable != null){
			Iterator<DoctorSchedulingTimes> it = iterable.iterator();
			while(it != null && it.hasNext()){
				DoctorSchedulingTimes dst = it.next();
				list.add(dst);
			}
		}
		return list;
	}

}
